home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / LIB211.ZIP;1 / OBSOLETE.PRG < prev    next >
Encoding:
Text File  |  1993-11-19  |  28.8 KB  |  715 lines

  1. *-----------------------------------------------------------------------
  2. *-- Program...: OBSOLETE.PRG
  3. *-- Programmer: Ken Mayer (CIS: 71333,1030)
  4. *-- Date......: 07/29/1993
  5. *-- Notes.....: The following functions are not necessary using dBASE 
  6. *--             IV, 1.5 (or in some cases, 2.0), but have been retained 
  7. *--             in the current version of the library system in order 
  8. *--             to have some compatibility with 1.1.
  9. *-----------------------------------------------------------------------
  10.  
  11. FUNCTION Empty
  12. *-----------------------------------------------------------------------
  13. *-- Programmer..: Jerry Wightman (WIGHTMAN)
  14. *-- Date........: ?
  15. *-- Notes.......: Used to check whether a memory variable in dBASE 
  16. *--               contains anything, based on type of field. (Pulled 
  17. *--               from BORBBS)
  18. *--               NOTE: In release 1.5, replace all calls to EMPTY() 
  19. *--               with the new:  ISBLANK() function. This will be 
  20. *--               faster.
  21. *-- Written for.: dBASE IV, 1.1
  22. *-- Rev. History: None
  23. *-- Calls.......: None
  24. *-- Called by...: Any
  25. *-- Usage.......: Empty(<cFld>)
  26. *-- Example.....: @5,10 say "Enter date: " get bDate;
  27. *--                         valid required .not. empty(bDate);
  28. *--                         error chr(7)+"** Date cannot be Empty! **"
  29. *-- Returns.....: Logical (.t./.f.)
  30. *-- Parameters..: cFld  =  Field/Memvar/Expression to check for 
  31. *--                        "Emptiness"
  32. *-----------------------------------------------------------------------
  33.  
  34.    PARAMETERS cFld  && may be memory variable or database field name
  35.    private cTalk, lReturn
  36.  
  37.    m->cTalk = SET("TALK")
  38.  
  39.    m->lReturn = .F.      &&  FALSE means:  variable is NOT empty
  40.  
  41.    do case
  42.       case type( "cFld" ) = "C"
  43.           if len( ltrim(rtrim( m->cFld )) ) = 0
  44.              m->lReturn = .T.
  45.           endif
  46.  
  47.       case type( "cFld" ) = "N" .or. type( "cFld" ) = "F"
  48.          if m->cFld = 0
  49.             m->lReturn = .T.
  50.          endif
  51.  
  52.       case type( "cFld" ) = "L"
  53.          m->lReturn = .F.  && Can't check logical fields
  54.  
  55.       case type( "cFld" ) = "D"
  56.          if m->cFld = {}
  57.             m->lReturn = .T.
  58.          endif
  59.  
  60.       case type( "cFld" ) = "M"
  61.          if len( m->cFld ) = 0
  62.             m->lReturn = .T.
  63.          endif
  64.  
  65.       otherwise   && TYPE = "U"
  66.          m->lReturn = .T.
  67.    endcase
  68.  
  69.    set talk &cTalk.
  70.    
  71. RETURN m->lReturn
  72. *-- EoF: Empty()
  73.  
  74. FUNCTION NumFlds
  75. *-----------------------------------------------------------------------
  76. *-- Programmer..: Bowen Moursund (CIS: 72662,436)
  77. *-- Date........: 07/12/1991
  78. *-- Notes.......: Returns the number of fields in a database structure -
  79. *--               only in the currently selected DBF
  80. *--               NOTE: In release 1.5, replace function NUMFLDS() with
  81. *--               FLDCOUNT() -- built in to 1.5, faster ...
  82. *-- Written for.: dBASE IV, 1.1
  83. *-- Rev. History: 07/12/1991 -- Original
  84. *-- Calls.......: None
  85. *-- Called by...: Any
  86. *-- Usage.......: NumFlds()
  87. *-- Example.....: ? NumFlds()
  88. *-- Returns.....: Number of fields
  89. *-- Parameters..: None
  90. *-----------------------------------------------------------------------
  91.  
  92.    private nFlds,cFldName
  93.    
  94.    *-- If currently selected database is empty (no dbf file)
  95.    if len(trim(dbf())) = 0
  96.       m->nFlds = 0                     && set to 0
  97.    *-- we have something ...
  98.    else
  99.       m->nFlds = 0                  && initialize
  100.       do while .t.                  && loop through the record structure
  101.          m->nFlds= m->nFlds + 1     && increment counter
  102.          m->cFldName = field(m->nFlds) && get fieldname
  103.          if len(trim(m->cFldName)) = 0 && if length = 0,
  104.             m->nFlds = m->nFlds - 1 &&   decrement counter
  105.             exit                    &&   get out of loop, we're done
  106.          endif                      && endif(length...)
  107.       enddo                         && end of loop
  108.    endif
  109.  
  110. RETURN m->nFlds
  111. *-- EoF: NumFlds()
  112.  
  113. FUNCTION DateSet
  114. *-----------------------------------------------------------------------
  115. *-- Programmer..: Jay Parsons (CIS: 72662,1302)
  116. *-- Date........: 03/01/1992
  117. *-- Notes.......: Returns string giving name of current DATE format
  118. *--               This is not needed in Version 1.5, in which 
  119. *--               set("DATE") returns the format.  Unlike that function
  120. *--               in 1.5, this one cannot distinguish between date 
  121. *--               formats set with different terms that amount to the 
  122. *--               same thing:
  123. *--                     DMY = BRITISH = FRENCH
  124. *--                     MDY = AMERICAN
  125. *--                     YMD = JAPAN
  126. *--               If your users will be using one of these formats and
  127. *--               are sensitive about the name, substitute the one they
  128. *--               want for the equivalent in this function.
  129. *-- Rev. History: 03/01/1992 -- Original
  130. *-- Written for.: dBASE IV, versions below 1.5
  131. *-- Rev. History: None
  132. *-- Calls.......: None
  133. *-- Called by...: Any
  134. *-- Usage.......: DateSet()
  135. *-- Example.....: ?DateSet()
  136. *-- Returns.....: Character
  137. *-- Parameters..: None
  138. *-----------------------------------------------------------------------
  139.  
  140.    private cCent, cTestdate, cDelimiter
  141.    m->cCent = set( "CENTURY" )
  142.    set century off
  143.    m->cTestDate = ctod( "01/02/03" )
  144.    m->cDelimiter = substr( dtoc( m->cTestDate ), 3, 1 )
  145.    set century &cCent.
  146.    do case
  147.       case month( m->cTestDate ) = 1
  148.          RETURN iif( m->cDelimiter = "-", "USA", "MDY" )
  149.       case day( m->cTestDate ) = 1
  150.          RETURN iif( m->cDelimiter = "/", "DMY", ;
  151.               iif( m->cDelimiter = ".", "GERMAN", "ITALIAN" ) )
  152.       otherwise
  153.          RETURN iif( m->cDelimiter = ".", "ANSI", "YMD" )
  154.    endcase
  155.    
  156. *-- EoF: DateSet()
  157.  
  158. FUNCTION Stampval
  159. *-----------------------------------------------------------------------
  160. *-- Programmer..: Jay Parsons (CIS: 72662,1302)
  161. *-- Date........: 04/07/1992
  162. *-- Notes.......: Passed a 16-character string in the form of the 
  163. *--               rightmost 16 characters returned by the DOS DIR 
  164. *--               command for a file, returns a number that will compare
  165. *--               properly in date/time order with the numbers returned 
  166. *--               by this function for other files.
  167. *-- Written for.: dBASE IV Versions below 1.5
  168. *-- Rev. History: 04/07/1992
  169. *-- Calls.......: None
  170. *-- Called by...: Any
  171. *-- Usage.......: Stampval(<cTimestamp>)
  172. *-- Example.....: IF Stampval("02-22-92  10:54a") > 
  173. *--                  Stampval("04-05-92   5:54p")
  174. *-- Returns.....: Numeric corresponding to time stamp of file
  175. *-- Parameters..: cStamp, a DIR timestamp
  176. *-----------------------------------------------------------------------
  177.  
  178.    parameters cStamp
  179.  
  180. RETURN 1440 * ( 12 * val( left(m->cStamp,2)) + ;
  181.      val(substr(m->cStamp,4,2)) + 372*val(substr(m->cStamp,7,2)) );
  182.      + 60 * val(substr(m->cStamp,11,2)) + ;
  183.      val(substr(m->cStamp,14,2)) + iif(right(m->cStamp,1)=;
  184.      "p",720,0)
  185. *--Eof() Stampval
  186.  
  187. PROCEDURE FullWin
  188. *-----------------------------------------------------------------------
  189. *-- Programmer..: Ken Mayer (CIS: 71333,1030)
  190. *-- Date........: 05/23/91
  191. *-- Notes.......: Overlays menus or another screen with a full window,
  192. *--               so that processing is done in the window, and one can 
  193. *--               return directly to the menus, without redrawing screen
  194. *--               and such. This routine may be a problem in dBASE IV, 
  195. *--               1.5 ... use with caution ...
  196. *--               NOTE: This routine was removed as completely 
  197. *--               unnecessary once I familiarized myself with SAVE SCREEN
  198. *--               and RESTORE SCREEN ... 
  199. *-- Written for.: dBASE IV, 1.1
  200. *-- Rev. History: 05/23/1991
  201. *-- Calls.......: None
  202. *-- Called by...: Any
  203. *-- Usage.......: do fullwin with <cColor>,<cWinName>,<cScreen>
  204. *-- Example.....: do fullwin with "w+/b","w_Edit","sc_Main"
  205. *--                * perform whatever actions are needed in the window
  206. *--               deactivate window wEdit
  207. *--               release window wEdit
  208. *--               restore screen from sMain
  209. *--               release screen sMain
  210. *-- Returns.....: None
  211. *-- Parameters..: cColor   = Colors for window
  212. *--               cWinName = Name of window
  213. *--               cScreen  = Name of screen
  214. *-----------------------------------------------------------------------
  215.    
  216.    parameters cColor,cWinName,sScreen
  217.    
  218.    define window &cWinName. from 0,0 to 23,79 none color &cColor.
  219.    save screen to &sScreen.
  220.    activate window &cWinName.
  221.    
  222. RETURN  
  223. *-- EoP: FullWin          
  224.  
  225. ********************************
  226. ** The following color routines
  227. ** were "retired" as I found
  228. ** better ways of doing things.
  229. ********************************
  230.    
  231. PROCEDURE SetColor
  232. *-----------------------------------------------------------------------
  233. *-- Programmer..: Phil Steele
  234. *-- Date........: 05/23/91
  235. *-- Notes.......: Used to set the screen colors for a system. It
  236. *--               checks to see if a color monitor is attached 
  237. *--               (ISCOLOR()), and sets system variables, that can be 
  238. *--               used in SET COLOR OF commands. You must define the 
  239. *--               memvars as PUBLIC, see Example below -- otherwise 
  240. *--               nothing will work.
  241. *-- Written for.: dBASE IV, 1.1
  242. *-- Rev. History: Borrowed from Phil Steele's PCSDEMO (a public domain
  243. *--               program) and commented a bit more, minor modifications 
  244. *--               by Ken Mayer 
  245. *-- Calls.......: None
  246. *-- Called by...: Any
  247. *-- Usage.......: do setcolor
  248. *-- Example.....: in a menu or setup program:
  249. *--               PUBLIC cl_blank,cl_func,cl_help,cl_data,cl_error,;
  250. *--                      cl_entry,cl_stand,cl_menu,cl_warn 
  251. *--               DO setcolor
  252. *--                  by declaring the variables PUBLIC before calling 
  253. *--                  SETCOLOR they should be globally available 
  254. *--                  throughout, unless you use a CLEAR ALL or RELEASE
  255. *--                  ALL command ...
  256. *-- Returns.....: None
  257. *-- Parameters..: None
  258. *-----------------------------------------------------------------------   
  259.  
  260.    if file("COLOR.MEM")
  261.       restore from Color.mem additive   && if color.mem exists, 
  262.                                         && restore from it
  263.    else                                 && otherwise, create it
  264.       m->lC   = iscolor()           && remember -- foreground/background
  265.       m->cl_Blank = "n/n,n/n,n"     && black on black on black ...
  266.       m->cl_Func  = "n/w"           && function keys (used in CLRSHOW)
  267.       * if iscolor() = true, define color, otherwise black/white
  268.       m->cl_Help  = iif(m->lC,"n/g,g/n,n"      , "w+/n,n/w,n")   
  269.       m->cl_Data  = iif(m->lC,"rg+/gb,gb/rg,n" , "n/w,w+/n,n")
  270.       m->cl_Error = iif(m->lC,"rg+/r,w/n,n"    , "w+/n,n/w,n")
  271.       m->cl_Entry = iif(m->lC,"n/w,w/n,n"      , "n/w,w/n,n") 
  272.       m->cl_Stand = iif(m->lC,"w+/b,b/w,n"     , "w+/n,n/w,n")
  273.       m->cl_Menu  = iif(m->lC,"rg+/b,b/w,n"    , "w+/n,n/w,n")
  274.       m->cl_Warn  = iif(m->lC,"rg+/r,w/n,n"    , "w/n,n/w,n") 
  275.       save to color all like cl_*      && create COLOR.MEM
  276.    endif
  277.    
  278.    *-- change current color settings to these ...
  279.    set color to &cl_stand.
  280.    cTemp = extrclr(m->cl_Data)  
  281.    set color of fields   to &cTemp.
  282.    set color of messages to &cTemp.
  283.    set color of box      to &cTemp.
  284.    cTemp = extrclr(m->cl_Stand)
  285.    set color of highlight to &cTemp.
  286.    
  287. RETURN
  288. *-- EoP: SetColor
  289.  
  290. PROCEDURE SetColor2
  291. *-----------------------------------------------------------------------
  292. *-- Programmer..: Phil Steele
  293. *-- Date........: 05/23/91
  294. *-- Notes.......: Used to set the screen colors for a system. It
  295. *--               checks a parameter passed by the programmer to see if 
  296. *--               the monitor is a color system. It then creates the 
  297. *--               proper color combinations based on this ... 
  298. *-- Written for.: dBASE IV, 1.1
  299. *-- Rev. History: Borrowed from Phil Steele's PCSDEMO (a public domain
  300. *--               program) and commented a bit more, minor modifications
  301. *--               by Ken Mayer 11/21/91 -- Modified for parameter ...
  302. *-- Calls.......: None
  303. *-- Called by...: Any
  304. *-- Usage.......: do setcolor2 with "<cYN>"
  305. *-- Example.....: in a menu or setup program:
  306. *--               PUBLIC cl_blank,cl_func,cl_help,cl_data,cl_error,;
  307. *--                      cl_entry,cl_stand,cl_menu,cl_warn 
  308. *--               DO setcolor2 with "Y"
  309. *--                  by declaring the variables PUBLIC before calling 
  310. *--                  SETCOLOR2 they should be globally available 
  311. *--                  throughout, unless you use a CLEAR ALL or RELEASE
  312. *--                  ALL command ...
  313. *-- Returns.....: None
  314. *-- Parameters..: cYN  =  "Y" for color, "N" for mono ...
  315. *-----------------------------------------------------------------------
  316.    
  317.    parameter cYN
  318.    private lC, cTemp
  319.    
  320.    m->lC = iif(cYN="Y",.t.,.f.)  && remember -- foreground/background
  321.    m->cl_Blank = "n/n,n/n,n"      && black on black on black ...
  322.    m->cl_Func  = "n/w"            && function keys
  323.    m->cl_Help  = iif(m->lC,"n/g,g/n,n"      , "w+/n,n/w,n")
  324.    m->cl_Data  = iif(m->lC,"rg+/gb,gb/rg,n" , "n/w,w+/n,n")
  325.    m->cl_Error = iif(m->lC,"rg+/r,w/n,n"    , "w+/n,n/w,n")
  326.    m->cl_Entry = iif(m->lC,"n/w,w/n,n"      , "n/w,w/n,n") 
  327.    m->cl_Stand = iif(m->lC,"w+/b,b/w,n"     , "w+/n,n/w,n")
  328.    m->cl_Menu  = iif(m->lC,"rg+/b,b/w,n"    , "w+/n,n/w,n")
  329.    m->cl_Warn  = iif(m->lC,"rg+/r,w/n,n"    , "w/n,n/w,n") 
  330.    save to color all like cl_*      && create COLOR.MEM
  331.    
  332.    *-- change current color settings to these ...
  333.    set color to &cl_stand.
  334.    cTemp = extrclr(m->cl_data)
  335.    set color of fields   to &cTemp.
  336.    set color of messages to &cTemp.
  337.    set color of box      to &cTemp.
  338.    cTemp = extrclr(m->cl_stand)
  339.    set color of highlight to &cTemp.
  340.    
  341. RETURN
  342. *-- EoP: SetColor2
  343.  
  344. FUNCTION ExtrClr
  345. *-----------------------------------------------------------------------
  346. *-- Programmer..: Ken Mayer (CIS: 71333,1030)
  347. *-- Date........: 05/24/1991
  348. *-- Notes.......: Used to extract the first parameter of the MEMVARS
  349. *--               created from SETCOLOR above. The SET COLOR OF commands
  350. *--               can only use the first parameter.
  351. *--               It is recommended that you run SetColor (above) first, 
  352. *--               although if you define your own color memvars, this 
  353. *--               will work just as well.
  354. *-- Written for.: dBASE IV, 1.1
  355. *-- Rev. History: 05/24/1991 -- Original
  356. *-- Calls.......: None
  357. *-- Called by...: Any
  358. *-- Usage.......: extrclr(<cMemVar>)
  359. *-- Example.....: set color of highlight to &extrclr(cl_stand)
  360. *-- Returns.....: "W+/B"
  361. *-- Parameters..: cMemVar = color memory variable to have colors 
  362. *--                         extracted from
  363. *-----------------------------------------------------------------------
  364.    
  365.    parameters cMemVar
  366.    
  367. RETURN substr(m->cMemVar,1,(at(",",m->cMemVar)-1)) 
  368. *-- EoF: ExtrClr()
  369.  
  370. FUNCTION InvClr
  371. *-----------------------------------------------------------------------
  372. *-- Programmer..: Ken Mayer (CIS: 71333,1030)
  373. *-- Date........: 05/23/1991
  374. *-- Notes.......: Used to set an inverse color, using value(s) returned
  375. *--               from extrclr above, or from a single color memvar.
  376. *--               Inverted colors may give odd results -- RG+ (yellow) 
  377. *--               is not a background color, for example, and will 
  378. *--               appear as RG (brown) -- this may not be what you 
  379. *--               wanted ...
  380. *-- Written for.: dBASE IV, 1.1
  381. *-- Rev. History: 05/23/1991 -- Original
  382. *-- Calls.......: None
  383. *-- Called by...: Any
  384. *-- Usage.......: invclr(<cMemVar>)
  385. *-- Example.....: set color of highlight to &invclr(extrclr(cl_stand))
  386. *--                    or
  387. *--               x = extrclr(cl_stand)
  388. *--               set color of highlight to &invclr(x)
  389. *-- Returns.....: "B/W+"
  390. *-- Parameters..: cMemVar = color variable containing colors to be 
  391. *--                         inverted
  392. *-----------------------------------------------------------------------
  393.  
  394.    parameters cMemVar
  395.    private cTemp1, cTemp2
  396.    
  397.    m->cTemp1 = substr(m->cMemVar,1,(at("/",m->cMemVar)-1))
  398.    m->cTemp2 = substr(m->cMemVar,(at("/",m->cMemVar)+1),len(m->cMemVar))
  399.  
  400. RETURN m->cTemp2+"/"+m->cTemp1
  401. *-- EoF: InvClr()
  402.  
  403. **********************************************************************
  404. ***** THE FOLLOWING WERE MOVED HERE FROM OTHER LIBRARY FILES FOLLOWING
  405. ***** THE RELEASE OF dBASE IV, 2.0.  KJM
  406. **********************************************************************
  407.  
  408. FUNCTION Rat
  409. *-----------------------------------------------------------------------
  410. *-- Programmer..: Jay Parsons (CIS: 72662,1302)
  411. *-- Date........: 03/01/1992
  412. *-- Notes.......: Reverse "at", returns position a character string is 
  413. *--               last AT in a larger string.
  414. *-- Written for.: dBASE IV
  415. *-- Rev. History: 03/01/1992 -- Original Release
  416. *-- Calls.......: None
  417. *-- Called by...: Any
  418. *-- Usage.......: Rat("<cFindStr>","<cBigStr>")
  419. *-- Example.....: ? Rat("Test","This is a Test string, with Test data")
  420. *-- Returns.....: Numeric value
  421. *-- Parameters..: cFindStr = string to find in cBigStr
  422. *--               cBigStr  = string to look in
  423. *-----------------------------------------------------------------------
  424.  
  425.    parameters cFindstr, cBigstr
  426.    private nPos,nLen
  427.    m->nLen = len( m->cFindStr )
  428.    m->nPos = len( m->cBigStr ) - m->nLen + 1
  429.    do while m->nPos > 0
  430.       if substr( m->cBigStr, m->nPos, m->nLen ) = m->cFindStr
  431.          exit
  432.       else
  433.          m->nPos = m->nPos - 1
  434.       endif
  435.    enddo
  436.    
  437. RETURN max( m->nPos, 0 )
  438. *-- EoF: RAt()
  439.  
  440. FUNCTION IsMouse
  441. *-----------------------------------------------------------------------
  442. *-- Programmer..: Ken Mayer (CIS: 71333,1030)
  443. *-- Date........: 06/18/1992
  444. *-- Notes.......: This is used to determine the presence of a mouse 
  445. *--               driver. Returns a .t. if a mouse driver is detected, 
  446. *--               a .f. otherwise. This routine will turn the mouse off,
  447. *--               automatically. This can be used to detect a mouse, and
  448. *--               turn it off, as well as to set a memvar to determine 
  449. *--               the current mouse state. For example, after running 
  450. *--               this routine, the mouse will be off (if there's a 
  451. *--               driver).
  452. *--               ******************************
  453. *--               **** REQUIRES JPMOUSE.BIN ****
  454. *--               ******************************
  455. *-- Written for.: dBASE IV, 1.5
  456. *-- Rev. History: 06/18/1992 -- Original
  457. *-- Calls.......: None
  458. *-- Called by...: Any
  459. *-- Usage.......: IsMouse()
  460. *-- Example.....: ?IsMouse()
  461. *-- Returns.....: Logical
  462. *-- Parameters..: None
  463. *-----------------------------------------------------------------------
  464.  
  465.    private cRetVal, lIsMouse, X
  466.    
  467.    Load JPMOUSE.BIN
  468.    m->cRetVal = call("JPMOUSE","?")
  469.    m->lIsMouse = iif(m->cRetVal="T",.t.,.f.)
  470.    if m->lIsMouse
  471.       x = call("JPMOUSE","H")
  472.    endif
  473.    release module JPMOUSE
  474.  
  475. RETURN m->lIsMouse
  476. *-- EoF: IsMouse()
  477.  
  478. PROCEDURE SetMouse
  479. *-----------------------------------------------------------------------
  480. *-- Programmer..: Ken Mayer (CIS: 71333,1030)
  481. *-- Date........: 06/18/1992
  482. *-- Notes.......: This is used to determine the presence of a mouse 
  483. *--               driver, and/or turn the mouse cursor off in dBASE IV, 
  484. *--               1.5
  485. *--               ******************************
  486. *--               **** Requires JPMOUSE.BIN ****
  487. *--               ******************************
  488. *-- Written for.: dBASE IV, 1.5
  489. *-- Rev. History: 06/18/1992 -- Original
  490. *-- Calls.......: None
  491. *-- Called by...: Any
  492. *-- Usage.......: Do SetMouse with <c_Mouse>
  493. *-- Example.....: PUBLIC c_Mouse
  494. *--               x=ismouse()             && function in MISC.PRG
  495. *--               store "OFF" to c_Mouse  && after calling IsMouse() 
  496. *--                                       && it's 'Off'
  497. *--               ON KEY LABEL Alt-M DO SetMouse
  498. *-- Returns.....: .T.
  499. *-- Parameters..: c_Mouse = A GLOBAL memory variable -- this can/will 
  500. *--                         be changed by this procedure to the opposite
  501. *--                         scenario when the routine is called. The 
  502. *--                         concept here is to switch the mouse on 
  503. *--                         and/or off if there's a mouse driver.
  504. *--                This memvar should be set to the current status of 
  505. *--                the mouse- if on, it should hold "ON" in it ...
  506. *-----------------------------------------------------------------------
  507.  
  508.    private X
  509.    
  510.    if type("m->c_Mouse") # "C"     && if c_Mouse has not been defined as
  511.       return                    &&   a character field, return
  512.    endif
  513.    
  514.    load JPMOUSE.BIN                && load the module
  515.    
  516.    *-- if the mouse is off, we're going to set it on ("S"), if on, we're
  517.    *-- going to set it off "H")
  518.    m->cSetMouse = iif(upper(m->c_Mouse) = "OFF","S","H") 
  519.    m->x=call("JPMOUSE",m->cSetMouse)      
  520.    
  521.    release module JPMOUSE           && remove from memory
  522.    
  523.    *-- if c_Mouse was 'off' we are setting it 'on', and vice versa
  524.    m->c_Mouse = iif(upper(m->c_Mouse) = "OFF","ON","OFF") 
  525.                                            && change state of c_Mouse
  526.  
  527. RETURN
  528. *-- EoP: SetMouse
  529.  
  530. FUNCTION IsUnique
  531. *********************************************************************
  532. **                ** WARNING WARNING WARNING **
  533. ** Extensive testing has shown that this routine causes problems in
  534. ** dBASE IV, 1.5 and later. Use SEEK() or SEEK  instead, to determine
  535. ** uniqueness (if FOUND() and all that ...)
  536. ** In Version 2.0, use KEYMATCH()
  537. **********************************************************************
  538. *-----------------------------------------------------------------------
  539. *-- Programmer..: Clinton L. Warren (VBCES)
  540. *-- Date........: 04/28/1992
  541. *-- Notes.......: Checks to see if an index key already exists in the 
  542. *--               current selected database. This function was inspired
  543. *--               by Tom Woodward's Chk4Dup UDF.
  544. *-- Written for.: dBASE IV, 1.1
  545. *-- Rev. History: May 15, 1991 Version 1.1  Added check for zero record
  546. *--                 database
  547. *--               May  7, 1991 Version 1.0  Initial 'release'.
  548. *--               04/28/1992 -- modified for dBASE IV, 1.5 due to 'new'
  549. *--               behavior (see READ.ME that comes with 1.5). Should 
  550. *--               function fine with 1.1 and 1.0. This change from David
  551. *--               Love (DAVIDLOVE).
  552. *--               NOTE: NEW PARAMETER
  553. *-- Calls.......: None
  554. *-- Called by...: Any
  555. *-- Usage.......: IsUnique(<xValue>,"<cOrder>","<cField>")
  556. *-- Example.....: @5,5 SAY "SSN: " GET SSN PICTURE "999-99-9999";
  557. *--                  valid required IsUnique(SSN, "SSN", "SSN");
  558. *--                  message "Enter a new SSN";
  559. *--                  error chr(7)+"SSN must be unique!"
  560. *-- Returns.....: .T./.F.
  561. *-- Parameters..: xValue = Value (any non-memo type) to check for 
  562. *--                        uniqueness
  563. *--               cOrder = MDX Tag used to order the database. Must be 
  564. *--                        set for field being checked.
  565. *--               cField = field name for 'get'.
  566. *-----------------------------------------------------------------------
  567.    
  568.    parameters xValue, cOrder, cField
  569.    private nRecNo, nRecCnt, cSetNear, cSetDel, lIsDeleted, cSetOrder
  570.    private lIsUnique
  571.    
  572.    m->nRecNo = recno()       && store current record number
  573.    m->nRecCnt = reccount()   && count records in database
  574.  
  575.    if m->nRecCnt = 0         && empty database, cValue MUST be unique
  576.       RETURN .t.
  577.    endif
  578.    
  579.    m->cSetNear = set('NEAR')  && store status of NEAR flag
  580.    set near off               && set it off
  581.    m->cSetDel = set('DELETE') && store status of DELETE
  582.    set delete on              && Delete must be ON for this to work
  583.    m->lIsDeleted = deleted()  && is current record deleted?
  584.    delete                     && set delete flag for current record
  585.    m->cSetOrder = order()     && store current MDX tag
  586.    set order to (m->cOrder)   && set tag to that sent to function
  587.    
  588.    if seek(m->xValue)         && does it exist already?
  589.       m->lIsUnique = .f.      &&   if so, it's not unique
  590.    else                       && otherwise,
  591.       m->lIsUnique = .t.      &&   it is.
  592.    endif
  593.    
  594.    set order to (cSetOrder)   && restore changed settings to 
  595.                               && original settings
  596.    set delete &cSetDel.
  597.    set near &cSetNear.
  598.    
  599.    if m->nRecNo > m->nRecCnt  && if called during an append
  600.       go bottom               && goto the bottom of the database,
  601.       skip 1                  &&   plus one record (the new one)
  602.       if m->lIsUnique         && this is the new part ...
  603.          replace &cField. with m->xValue
  604.       endif
  605.    else
  606.       go m->nRecNo            && otherwise, goto the current record 
  607.                               && number
  608.    endif
  609.  
  610.    if .not. m->lIsDeleted     && was record 'deleted' before?
  611.       recall                  && if not, undelete it ... (turn flag off)
  612.    endif 
  613.  
  614. RETURN (m->lIsUnique)
  615. *-- EoF: IsUnique()
  616.  
  617. FUNCTION Delay
  618. *-----------------------------------------------------------------------
  619. *-- Programmer..: Jay Parsons (CIS: 72662,1302)
  620. *-- Date........: 03/01/1992
  621. *-- Notes.......: Delay Loop.  Returns .T. after lapse of given number 
  622. *--               of seconds.  Accurate to one second.  For dBASE IV 
  623. *--               2.0, use the upgraded version in Time.prg.
  624. *--               This may be used in conjunction with EXACTIME.BIN or a
  625. *--               similar routine that obtains the tick count.  In that 
  626. *--               case, the delay may be made accurate to one tick.  
  627. *--               To use it this way, add:
  628. *--                             LOAD Exactime
  629. *--                             Arg = space(11)
  630. *--               and substitute for each call of the time() function:
  631. *--                             call( "Exactime", Arg )
  632. *--
  633. *-- Written for.: dBASE IV, Versions below 2.0
  634. *-- Rev. History: 03/01/1992 -- Original function
  635. *--               04/20/1993 -- modified to deal with fractions, bug 
  636. *--                            fixed
  637. *-- Calls.......: TIME2SEC()           Function in TIME.PRG
  638. *-- Called by...: Any
  639. *-- Usage.......: Delay(<nSeconds>)
  640. *-- Example.....: lX= Delay(10.25)
  641. *-- Returns.....: Logical
  642. *-- Parameters..: nSeconds = number of seconds to delay
  643. *-----------------------------------------------------------------------
  644.  
  645.    parameters nSeconds         && up to 86400, one day
  646.    private nTimeout, nTimenow, lRollover
  647.    m->nTimeOut = 100 * ( Time2Sec( time() ) + m->nSeconds )
  648.    if m->nTimeOut > 8640000
  649.       m->lRollOVer = .T.
  650.       m->nTimeOut = m->nTimeOut - 8640000
  651.    else
  652.       m->lRollOVer = .F.
  653.    endif
  654.    do while .T.
  655.       m->nTimeNow = 100 * Time2Sec( time() )
  656.       if m->nTimeNow < m->nTimeOut
  657.          m->lRollOVer = .F.
  658.       else
  659.          if .not. m->lRollOVer
  660.              exit
  661.          endif
  662.       endif
  663.    enddo
  664.  
  665. RETURN .T.
  666. *-- EoF: Delay()
  667.  
  668. FUNCTION DateSet
  669. *-----------------------------------------------------------------------
  670. *-- Programmer..: Jay Parsons (CIS: 72662,1302)
  671. *-- Date........: 03/01/1992
  672. *-- Notes.......: Returns string giving name of current DATE format
  673. *--               This is not needed in Version 1.5, where set("DATE")
  674. *--               returns the format.  Unlike that function in 1.5, this
  675. *--               one cannot distinguish between date formats set with
  676. *--               different terms that amount to the same thing:
  677. *--                     DMY = BRITISH = FRENCH
  678. *--                     MDY = AMERICAN
  679. *--                     YMD = JAPAN
  680. *--               If your users will be using one of these formats and
  681. *--               are sensitive about the name, substitute the one they
  682. *--               want for the equivalent returned by this function.
  683. *-- Rev. History: 03/01/1992 -- Original Release
  684. *-- Written for.: dBASE IV, versions below 1.5
  685. *-- Rev. History: None
  686. *-- Calls.......: None
  687. *-- Called by...: Any
  688. *-- Usage.......: DateSet()
  689. *-- Example.....: ?DateSet()
  690. *-- Returns.....: Character
  691. *-- Parameters..: None
  692. *-----------------------------------------------------------------------
  693.  
  694.    private cCent, cTestdate, cDelimiter
  695.    m->cCent = set( "CENTURY" )
  696.    set century off
  697.    m->cTestdate = ctod( "01/02/03" )
  698.    m->cDelimiter = substr( dtoc( m->cTestdate ), 3, 1 )
  699.    set century &cCent.
  700.    do case
  701.       case month( m->cTestdate ) = 1
  702.            RETURN iif( m->cDelimiter = "-", "USA", "MDY" )
  703.       case day( m->cTestdate ) = 1
  704.            RETURN iif( m->cDelimiter = "/", "DMY", ;
  705.                   iif( m->cDelimiter = ".", "GERMAN", "ITALIAN" ) )
  706.       otherwise
  707.            RETURN iif( m->cDelimiter = ".", "ANSI", "YMD" )
  708.    endcase
  709.    
  710. *-- EoF: DateSet()
  711.  
  712. *-----------------------------------------------------------------------
  713. *-- End of Program: OBSOLETE.PRG
  714. *-----------------------------------------------------------------------
  715.